from classes import album


def get_template(album: album.Album):
    template = f""

    albumartist = album.getAlbumArtist()
    artist = album.getArtist()

    genre = album.getGenre("/")
    subgenre = album.getSubgenre("/")

    releasedate = album.getReleaseDate()

    for element in album.getAlbumArtist():
        template += f"#{element.replace(' ', '_')}, "
    template = template[:-2]

    template += f" — {album.getAlbum().replace('EP', '').replace('LP', '').strip()} #"

    if len(artist) > 0:
        template += " (w/ "
        for element in artist:
            if not element in albumartist:
                template += f"#{element.replace(' ', '_')}, "
        template = template[:-2]
        template += ")"

    template += "\n\nGenre: "
    for element in genre:
        template += f"#{element.replace(' ', '').replace('-', '').replace('&', 'and').replace('’', '')}, "
    template = template[:-2]

    template += "\nStyle: "
    for element in subgenre:
        template += f"#{element.replace(' ', '').replace('-', '').replace('&', 'and').replace('’', '')}, "
    template = template[:-2]

    template += f"\nreleased {releasedate.strftime('%B')} {releasedate.strftime('%d')}, {releasedate.strftime('%Y')}"

    template += "\n\n"
    template += "Tracklist:\n"
    for num, track in enumerate(album.tracks):
        template += f"{num + 1}. {track.artist} — {track.title} ["
        for genre in track.genre.split("/"):
            template += f"{genre} / "
        template = template[:-3]
        template += "]\n"

    return template
